package code;

/**
 * 
 * Contains the savings account information. 
 *
 */
public class SavingsAccount extends BankAccounts{
	private static double interestRate = 1.25;
	
	/**
	 * Creates SavingsAccount
	 */
	public SavingsAccount()
	{
		fAccountNumber = fNextAccountNumber;
		fNextAccountNumber++;
	}
	
	/**
	 * Calculates te interest. 
	 */
	public void calculateInterest()
	{
		fBalance = fBalance + (fBalance * interestRate / 100);
	}
	
	@Override
	public boolean withdrawal(double amount)
	{
		if(((fBalance - amount) < 0))
		{
			return false;
		}
		else
		{
			fBalance = fBalance - amount;
			return true;
		}
	}
	
	@Override
	public boolean equals(Object o)
	{
		if(fAccountNumber == ((SavingsAccount)o).fAccountNumber)
			return true;
		else
			return false;
				
	}
}
